<?php

namespace App\Http\Controllers\before;
use App\Http\Controllers\Controller;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Eloquent;
class PageController  extends Controller
{
    const  logo='';
    public  function index(){
        $info['info']=DB::select('select * from goods');
       return view('Page.index',$info);
    }
    public function select()
    {

       $info= DB::table('brand')->get();
//       var_dump($info);die();
        return view('Page.select',['info'=>$info]);
    }

    public function edit($id){
        $assign=DB::table('brand')->find($id);


        return view('Page.edit',['assign'=>$assign]);
    }
    public function doedit(Request $request){
        $id=$request->post('id');
        $assign=$request->all();
//        dd($assign);
        unset($assign['id']);
        $assign=$this->delToken($assign);

//     dd($assign);
        $assign['logo'] = $this->uploadFile($assign['logo']);
        //var_dump($assign);die;
        $res= DB::table('brand')->where('id',$id)->update($assign);
        if($res){
            return redirect('/before/Page/select');
        }else{
         return '修改失败';
        }
    }


    public function zhao(){
        $info=DB::table('zhao')->get();

        return view('Page.zhao',['info'=>$info]);
    }
    public function xiangqing(){
            return view('Page.xiangqing');
    }
    public function tianzhuan(){




        return redirect('/before/ProDet/index',$info);


    }



}